package easy;

public class Solution_507 {

    /*public boolean checkPerfectNumber(int num) {
        if (num==1) return false;
        int count = 1;
        for (int i = 2; i <= Math.sqrt(num); i++) {
            if (num % i == 0) {
                count += i;
                int temp = num / i;
                if (i != temp) {
                    count += temp;
                }
//                System.out.println(i + "," + temp);
            }
        }
        return num == count;
    }*/

    public boolean checkPerfectNumber(int num) {
        if (num==1) return false;
        int count = 1;
        for (int i = 2; i <= Math.sqrt(num); i++) {
            if (num % i == 0) {
                count += i;
                count += num / i;
            }
        }
        return num == count;
    }

    public static void main(String[] args) {
        Solution_507 model = new Solution_507();
//        System.out.println(model.checkPerfectNumber(33550336));
        for (int i = 2; i <= Integer.MAX_VALUE; i++) {
            boolean b = model.checkPerfectNumber(i);
            if (b) {
                System.out.println(i);
            }
        }

    }
}
